Set-up and Load in Data

I first loaded in the dplyr, readXL and png packages in order to replicate the data. Dplyr aims to provide a function for each basic verb of data manipulation, readXl package makes it easy to get data out of Excel, png allows for graphics to be embedded into the r-markdon. After I loaded my packages I recreated the table as outlined in Green et al. (2012) and read it into to R.
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(readxl)
library(png)
Arctic_Carn <- read_excel("~/Desktop/Data.xlsx")
head(Arctic_Carn)
## # A tibble: 6 × 13
##   Code  Family  Species          Sex   Diet  `Body mass (kg)` `Skull length (mm…
##   <chr> <chr>   <chr>            <chr> <chr>            <dbl>              <dbl>
## 1 VLA   Canidae Vulpes lagopus   M     V                 5.75               140.
## 2 VLA   Canidae Vulpes lagopus   F     V                 5.75               119.
## 3 CLA   Canidae Canis latrans    M     V/NV             13                  178.
## 4 CLA   Canidae Canis latrans    F     V/NV             13                  178.
## 5 CLUa  Canidae Canis lupus arc… M     V                44.5                239.
## 6 CLUb  Canidae Canis lupus bai… M     V                38                  236.
## # … with 6 more variables: Chamber volume (mm3) <dbl>, TTSA (mm2) <dbl>,
## #   RTSA (mm2) <dbl>, OTSA (mm2) <dbl>, OTSA/RTSA <dbl>, Arctic/Temperate <chr>

Select data

I used the select() to select for only the columns that I needed. Species name, diet, and sex was not pertinent to this replication so it was left out. Since I was creating a new table I used the infix operator %>% to pass the left hand side of the operator to the first argument of the right hand side of the operator.
Arctic_Carn_Clean <- Arctic_Carn %>% dplyr::select(Code, Family,Diet, "Body mass (kg)", "Skull length (mm)", "Chamber volume (mm3)", "TTSA (mm2)", "RTSA (mm2)", "OTSA (mm2)", "OTSA/RTSA" )
head(Arctic_Carn_Clean)
## # A tibble: 6 × 10
##   Code  Family  Diet  `Body mass (kg)` `Skull length (mm)` `Chamber volume (mm3…
##   <chr> <chr>   <chr>            <dbl>               <dbl>                 <dbl>
## 1 VLA   Canidae V                 5.75                140.                23397.
## 2 VLA   Canidae V                 5.75                119.                19991.
## 3 CLA   Canidae V/NV             13                   178.                49723.
## 4 CLA   Canidae V/NV             13                   178.                46113 
## 5 CLUa  Canidae V                44.5                 239.               164810 
## 6 CLUb  Canidae V                38                   236.               102307 
## # … with 4 more variables: TTSA (mm2) <dbl>, RTSA (mm2) <dbl>,
## #   OTSA (mm2) <dbl>, OTSA/RTSA <dbl>

Pander

Once the data was cleaned up a bit I used the pander package so I could use the mutuate(). Mutate is a package that allows you to add new variables while preserving others. Here I was able to create new columns of log10 that I needed for the replication assignment.I did not use head() for this portion so you can see the log10 values that I created.
library(pander)
Arctic_Carn_Clean_log <- mutate(Arctic_Carn_Clean, lnBM=log10(Arctic_Carn_Clean$`Body mass (kg)`), lnSL=log10(Arctic_Carn_Clean$`Skull length (mm)`), lnCV=log10(Arctic_Carn_Clean$`Chamber volume (mm3)`), lnTTSA=log10(Arctic_Carn_Clean$`TTSA (mm2)`), lnRTSA=log10(Arctic_Carn_Clean$`RTSA (mm2)`), lnOTSA=log10(Arctic_Carn_Clean$`OTSA (mm2)`), lnOTSARTSA=log10(Arctic_Carn_Clean$`OTSA/RTSA`))
Arctic_Carn_Clean_log
## # A tibble: 38 × 17
##    Code  Family  Diet  `Body mass (kg)` `Skull length (mm)` `Chamber volume (mm…
##    <chr> <chr>   <chr>            <dbl>               <dbl>                <dbl>
##  1 VLA   Canidae V                 5.75                140.               23397.
##  2 VLA   Canidae V                 5.75                119.               19991.
##  3 CLA   Canidae V/NV             13                   178.               49723.
##  4 CLA   Canidae V/NV             13                   178.               46113 
##  5 CLUa  Canidae V                44.5                 239.              164810 
##  6 CLUb  Canidae V                38                   236.              102307 
##  7 CLUb  Canidae V                38                   236               100633.
##  8 LPI   Canidae V                19.8                 194.              114255.
##  9 NPR   Canidae NV                7                   127.               15929.
## 10 NPR   Canidae NV                7                   124.               16439.
## # … with 28 more rows, and 11 more variables: TTSA (mm2) <dbl>,
## #   RTSA (mm2) <dbl>, OTSA (mm2) <dbl>, OTSA/RTSA <dbl>, lnBM <dbl>,
## #   lnSL <dbl>, lnCV <dbl>, lnTTSA <dbl>, lnRTSA <dbl>, lnOTSA <dbl>,
## #   lnOTSARTSA <dbl>

Replication

During this step I was able to select for the new log10 columns that I created to replicate the regression models that were in Green et al. (2012). ggplot() was used to create ggplt1-ggplt5. The the first three figures (as seen below) are from Green et al. (2012). They are of total turbinate surface area (TTSA) vs Skull Length (SL), respiratory turbinate surface area (RTSA) vs body mass (kg) (BM), and respiratory surface area (RTSA) vs chamber volume (CV)

Figure 2 from Green et al. (2012)

I loaded ggplot2 into R to create my graphics and used using geom_point() to tell R to select a shape based upon Family (e.g., Canidae or Arctoidea). Originally the graph axis were in increments of 1.0 so I used scale_x_continuous(breaks=seq()) and scale_y_continuous(breaks=seq()) to set the axis to the increments that were in Green et al. (2012) so as you see they differ between the five figures. Stat_smooth was used to get the linear regression. “Fullrange=True” was used because without it would only place a regression point from the start end of each the families that I used. This function allowed for a regression to go all the way through and not halfway. You will see two stat_smooth functions because one was for the linear regression without considering canids and arctoids and the other one is to have two separate regression lines for each Family.
library(ggplot2)
ggplt1 <- ggplot(Arctic_Carn_Clean_log, aes(Arctic_Carn_Clean_log$lnSL, Arctic_Carn_Clean_log$lnTTSA)) + geom_point(aes(shape=Family)) +
 
  scale_x_continuous(breaks=seq(1.6,2.6,by=.2)) + scale_y_continuous(breaks=seq(3.5,5.5,by=.5)) +
stat_smooth(method = "lm", se=FALSE,fullrange=TRUE, color="black", size=.3,
                                                                aes(shape=Family)) +
  
  stat_smooth(method = "lm",
              formula =y ~ x,se = FALSE, color="red", size=.3) +
 
  
  
  labs(x = "Log10 skull length (mm)", y = "Log10 total turbinal surface area (mm2)") + geom_text(aes(label=Code), size=2, data=Arctic_Carn_Clean_log) + theme(
  panel.border = element_blank(), 
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank(),
  axis.line = element_line(colour = "black") )
## Warning: Ignoring unknown aesthetics: shape
ggplt1 + theme(legend.position = "none") +
  theme(legend.title = element_blank(),
        legend.spacing.y = unit(0, "mm"),
        panel.border = element_rect(colour = "black", fill=NA),
        aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black"))
## Warning: Use of `Arctic_Carn_Clean_log$lnSL` is discouraged. Use `lnSL` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnTTSA` is discouraged. Use `lnTTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnSL` is discouraged. Use `lnSL` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnTTSA` is discouraged. Use `lnTTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnSL` is discouraged. Use `lnSL` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnTTSA` is discouraged. Use `lnTTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnSL` is discouraged. Use `lnSL` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnTTSA` is discouraged. Use `lnTTSA`
## instead.
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_text).

library(ggplot2)
ggplt2 <- ggplot(Arctic_Carn_Clean_log, aes(Arctic_Carn_Clean_log$lnBM, Arctic_Carn_Clean_log$lnRTSA)) + geom_point(aes(shape=Family)) +
 
  scale_x_continuous(breaks=seq(-0.5,2.5,by=.5)) + scale_y_continuous(breaks=seq(2.5,5.0,by=.5)) +
stat_smooth(method = "lm", se=FALSE,fullrange=TRUE, color="black", size=.3,
                                                                aes(shape=Family)) +
  
  stat_smooth(method = "lm",
              formula =y ~ x,se = FALSE, color="red", size=.3) +
 
  
  
  labs(x = "Log10 mass (kg)", y = "Log10 respiratory turbinal surface area (mm2)") + geom_text(aes(label=Code), size=2, data=Arctic_Carn_Clean_log) + theme(
  panel.border = element_blank(), 
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank(),
  axis.line = element_line(colour = "black") )
## Warning: Ignoring unknown aesthetics: shape
ggplt2 + theme(legend.position = "none") +
  theme(legend.title = element_blank(),
        legend.spacing.y = unit(0, "mm"),
        panel.border = element_rect(colour = "black", fill=NA),
        aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black"))
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## `geom_smooth()` using formula 'y ~ x'

library(ggplot2)
ggplt3 <- ggplot(Arctic_Carn_Clean_log, aes(Arctic_Carn_Clean_log$lnCV, Arctic_Carn_Clean_log$lnRTSA)) + geom_point(aes(shape=Family)) +
 
  scale_x_continuous(breaks=seq(3.0,6.0,by=.5)) + scale_y_continuous(breaks=seq(2.5,5.0,by=.5)) +
stat_smooth(method = "lm", se=FALSE,fullrange=TRUE, color="black", size=.3,
                                                                aes(shape=Family)) +
  
  stat_smooth(method = "lm",
              formula =y ~ x,se = FALSE, color="red", size=.3) +
 
  
  
  labs(x = "Log10 mass (kg)", y = "Log10 olfactory turbinal surface area (mm2)") + geom_text(aes(label=Code), size=2, data=Arctic_Carn_Clean_log) + theme(
  panel.border = element_blank(), 
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank(),
  axis.line = element_line(colour = "black") )
## Warning: Ignoring unknown aesthetics: shape
ggplt3 + theme(legend.position = "none") +
  theme(legend.title = element_blank(),
        legend.spacing.y = unit(0, "mm"),
        panel.border = element_rect(colour = "black", fill=NA),
        aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black"))
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## `geom_smooth()` using formula 'y ~ x'

Figure 3 from Green et al. (2012)

library(ggplot2)
ggplt4 <- ggplot(Arctic_Carn_Clean_log, aes(Arctic_Carn_Clean_log$lnBM, Arctic_Carn_Clean_log$lnOTSA)) + geom_point(aes(shape=Family)) +
 
  scale_x_continuous(breaks=seq(-0.5,2.5,by=.5)) + scale_y_continuous(breaks=seq(3.5,5.5,by=.5)) +
stat_smooth(method = "lm", se=FALSE,fullrange=TRUE, color="black", size=.3,
                                                                aes(shape=Family)) +
  
  stat_smooth(method = "lm",
              formula =y ~ x,se = FALSE, color="red", linetype = "dashed", size=.3) +
 
  
  
  labs(x = "Log10 mass (kg)", y = "Log10 olfactory turbinal surface area (mm2)") + geom_text(aes(label=Code), size=2, data=Arctic_Carn_Clean_log) + theme(
  panel.border = element_blank(), 
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank(),
  axis.line = element_line(colour = "black") )
## Warning: Ignoring unknown aesthetics: shape
ggplt4 + theme(legend.position = "none") +
  theme(legend.title = element_blank(),
        legend.spacing.y = unit(0, "mm"),
        panel.border = element_rect(colour = "black", fill=NA),
        aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black"))
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnBM` is discouraged. Use `lnBM` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## `geom_smooth()` using formula 'y ~ x'

library(ggplot2)
ggplt5 <- ggplot(Arctic_Carn_Clean_log, aes(Arctic_Carn_Clean_log$lnCV, (Arctic_Carn_Clean_log$lnOTSA))) + geom_point(aes(shape=Family)) +
 
  scale_x_continuous(breaks=seq(3.0,6.0,by=.5)) + scale_y_continuous(breaks=seq(3.5,5.5,by=.5)) +
 
stat_smooth(method = "lm", se=FALSE,fullrange=TRUE, color="black", size=.3,
                                                                aes(shape=Family)) +  stat_smooth(method = "lm",
              formula =y ~ x,se = FALSE, color="red", size=.3, linetype = "dashed") +
  labs(x = "Log10 chamber volume (mm3)", y = "Log10 olfactory turbinal surface area (mm2)")  + geom_text(aes(label=Code), size=2, data=Arctic_Carn_Clean_log) + theme(
  panel.border = element_blank(), 
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank(),
  axis.line = element_line(colour = "black"))
## Warning: Ignoring unknown aesthetics: shape
ggplt5 + theme(legend.position = "none") +
  theme(legend.title = element_blank(),
        legend.spacing.y = unit(0, "mm"),
        panel.border = element_rect(colour = "black", fill=NA),
        aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black"))
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## `geom_smooth()` using formula 'y ~ x'

Figure 4 from Green et al. (2012)

library(ggplot2)
ggplt6 <- ggplot(Arctic_Carn_Clean_log, aes(Arctic_Carn_Clean_log$lnCV, (Arctic_Carn_Clean_log$lnOTSA))) + geom_point(aes(color=Diet, shape=Diet)) +
 
  scale_x_continuous(breaks=seq(3.0,6.0,by=.5)) + scale_y_continuous(breaks=seq(3.5,5.5,by=.5)) +  stat_smooth(method = "lm",
              formula =y ~ x,se = FALSE, color="black", size=.3) +
  labs(x = "Log10 chamber volume (mm3)", y = "Log10 olfactory turbinal surface area (mm2)")  + geom_text(aes(label=Code), size=2, data=Arctic_Carn_Clean_log) + theme(
  panel.border = element_blank(), 
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank(),
  axis.line = element_line(colour = "black")) +
  scale_shape_discrete(labels = c("Non-vetebrate", "Vertebrate","Vertebrate/Non-vertebrate")) +
  scale_colour_discrete(labels = c("Non-vetebrate", "Vertebrate","Vertebrate/Non-vertebrate")) +
  theme(legend.title = element_blank(),
        legend.spacing.y = unit(0, "mm"),
        panel.border = element_rect(colour = "black", fill=NA),
        aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black")) + theme(legend.position = c(0.25, 0.85))
ggplt6
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnCV` is discouraged. Use `lnCV` instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.

ggplt7 <- ggplot(Arctic_Carn_Clean_log, aes(Arctic_Carn_Clean_log$lnRTSA, (Arctic_Carn_Clean_log$lnOTSA))) + geom_point(aes(color=Diet, shape=Diet)) +
 
  scale_x_continuous(breaks=seq(2.5,5.0,by=.5)) + scale_y_continuous(breaks=seq(3.5,5.5,by=.5)) +
    stat_smooth(method = "lm",
              formula =y ~ x,se = FALSE, color="black", size=.3) +
  labs(x = "Log10 chamber volume (mm3)", y = "Log10 olfactory turbinal surface area (mm2)")  + geom_text(aes(label=Code), size=2, data=Arctic_Carn_Clean_log) + theme(
  panel.border = element_blank(), 
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank(),
  axis.line = element_line(colour = "black")) +
  scale_shape_discrete(labels = c("Non-vetebrate", "Vertebrate","Vertebrate/Non-vertebrate")) +
  scale_colour_discrete(labels = c("Non-vetebrate", "Vertebrate","Vertebrate/Non-vertebrate")) +
  theme(legend.title = element_blank(),
        legend.spacing.y = unit(0, "mm"),
        panel.border = element_rect(colour = "black", fill=NA),
        aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12),
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "black")) + theme(legend.position = c(0.25, 0.85))
ggplt7
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnRTSA` is discouraged. Use `lnRTSA`
## instead.
## Warning: Use of `Arctic_Carn_Clean_log$lnOTSA` is discouraged. Use `lnOTSA`
## instead.

Problems

Issues

Note: in ggplot6 and ggplot7 I tried to change the color and shape to match Green et al. (2012) and was using scale_color_manual to do but it kept adding the orgininal V, NV, V/NV that was in the data set that I recreated along with manual override. The diet is correct but I do not know how they were able to select for specific coloring and ordering of the legend without making a new table.I was having issues getting the figures to be exactly the same for ggplot1-5 because for the normal regression line the the authors made a dashed line and color coded the arctoids and canids as different colors but I was not sure on how to do that because if changed the line type when selecting for Family it would have changed both.

Ursus maritimus out